/* Copyright 2013-2015 www.snakerflow.com.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.snaker.engine.entity;

import java.io.Serializable;
import org.snaker.engine.model.ProcessModel;
import lombok.Data;

/**
 * 流程定义实体类
 * 
 * @author yuqs
 * @since 1.0
 */
@Data
public class Process implements Serializable {
    private static final long serialVersionUID = 6541688543201014542L;
    private String id; // 主键ID
    private Integer version; // 版本
    private String name; // 流程定义名称
    private String displayName; // 流程定义显示名称
    private String type; // 流程定义类型（预留字段）
    private String instanceUrl; // 当前流程的实例url（一般为流程第一步的url） 该字段可以直接打开流程申请的表单
    private Integer state; // 是否可用的开关
    private String createTime; // 创建时间
    private String creator; // 创建人
    private ProcessModel model; // 流程定义模型
    private String content; // 流程定义xml
    private byte[] bytes; // 流程定义字节数组

    /**
     * setter name/displayName/instanceUrl
     * 
     * @param processModel
     */
    public void setModel(ProcessModel processModel) {
        this.model = processModel;
        this.name = processModel.getName();
        this.displayName = processModel.getDisplayName();
        this.instanceUrl = processModel.getInstanceUrl();
    }

    // public byte[] getDBContent() {
    // if (this.content != null) {
    // return this.content.getBytes();
    // }
    // return bytes;
    // }
}
